home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Startrek.ifs < prev    next >
Text File  |  2005-03-13  |  13KB  |  285 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=DarkInk <link>http://www.darkink.tk</link>
  8. Title=startrek.com
  9. Description=www.startrek.com episode import
  10. Site=www.startrek.com
  11. Language=EN
  12. Version=20050119
  13. Requires=3.5.0
  14. Comments= v20050119 - Script update, Added Enterprise Season 4.| v20050114 - Script update, Site changed a little.| v20040203 - First version.|
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. Program StarTrek;
  23. Var
  24.   IndexURL    : String;
  25.   EpisodeURL  : String;
  26.   Tmp         : String;
  27.  
  28. Function ShowSeries : Boolean;
  29. Begin
  30.   PickTreeClear;
  31.   PickTreeAdd('The Original Serie (TOS)', '');
  32.     PickTreeAdd('Season 1', 'http://www.startrek.com/startrek/view/series/TOS/episodes/index.html?season=1&category=production');
  33.     PickTreeAdd('Season 2', 'http://www.startrek.com/startrek/view/series/TOS/episodes/index.html?season=2&category=production');
  34.     PickTreeAdd('Season 3', 'http://www.startrek.com/startrek/view/series/TOS/episodes/index.html?season=3&category=production');
  35.   PickTreeAdd('The Next Generation (TNG)', '');
  36.     PickTreeAdd('Season 1', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=1&category=production');
  37.     PickTreeAdd('Season 2', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=2&category=production');
  38.     PickTreeAdd('Season 3', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=3&category=production');
  39.     PickTreeAdd('Season 4', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=4&category=production');
  40.     PickTreeAdd('Season 5', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=5&category=production');
  41.     PickTreeAdd('Season 6', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=6&category=production');
  42.     PickTreeAdd('Season 7', 'http://www.startrek.com/startrek/view/series/TNG/episodes/index.html?season=7&category=production');
  43.   PickTreeAdd('Deep Space Nine (DS9)', '');
  44.     PickTreeAdd('Season 1', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=1&category=production');
  45.     PickTreeAdd('Season 2', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=2&category=production');
  46.     PickTreeAdd('Season 3', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=3&category=production');
  47.     PickTreeAdd('Season 4', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=4&category=production');
  48.     PickTreeAdd('Season 5', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=5&category=production');
  49.     PickTreeAdd('Season 6', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=6&category=production');
  50.     PickTreeAdd('Season 7', 'http://www.startrek.com/startrek/view/series/DS9/episodes/index.html?season=7&category=production');
  51.   PickTreeAdd('Voyager (VOY)', '');
  52.     PickTreeAdd('Season 1', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=1&category=production');
  53.     PickTreeAdd('Season 2', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=2&category=production');
  54.     PickTreeAdd('Season 3', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=3&category=production');
  55.     PickTreeAdd('Season 4', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=4&category=production');
  56.     PickTreeAdd('Season 5', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=5&category=production');
  57.     PickTreeAdd('Season 6', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=6&category=production');
  58.     PickTreeAdd('Season 7', 'http://www.startrek.com/startrek/view/series/VOY/episodes/index.html?season=7&category=production');
  59.   PickTreeAdd('Enterprise (ENT)', '');
  60.     PickTreeAdd('Season 1', 'http://www.startrek.com/startrek/view/series/ENT/episodes/index.html?season=1&category=production');
  61.     PickTreeAdd('Season 2', 'http://www.startrek.com/startrek/view/series/ENT/episodes/index.html?season=2&category=production');
  62.     PickTreeAdd('Season 3', 'http://www.startrek.com/startrek/view/series/ENT/episodes/index.html?season=3&category=production');
  63.     PickTreeAdd('Season 4', 'http://www.startrek.com/startrek/view/series/ENT/episodes/index.html?season=4&category=production');
  64.   ShowSeries := PickTreeExec(IndexURL);
  65. End;
  66.  
  67. Function CleanString(Str : String) : String;
  68. Begin
  69.   Str := StringReplace(Str, '<P>', #13#10);
  70.   HTMLDecode(Str);
  71.   HTMLRemoveTags(Str);
  72.   Str := Trim(Str);
  73.   Str := StringReplace(Str, #09, '');
  74.   If Pos(#13#10, Str) = 1 Then Begin
  75.     Str := Copy(Str, 3, Length(Str) - 2);
  76.   End;
  77.   CleanString := Str;
  78. End;
  79.  
  80. Function ShowEpisodes : Boolean;
  81. Var
  82.   Page      : TStringList;
  83.   I, J, K   : Integer;
  84.   Str       : String;
  85.   Tmp, Tmp1 : String;
  86.   Url       : String;
  87.   Title     : String;
  88.   EpisodeNo : String;
  89. Begin
  90.   PickTreeClear;
  91.   PickTreeAdd('Episodes', '');
  92.   Page := TStringList . Create;
  93.   Page . Text := GetPage(IndexURL);
  94.   I := 1;
  95.   While I < Page . Count Do Begin
  96.     Str := Page . GetString(I);
  97.     Tmp := '<td width="230" valign="top"><img src="images/spacer.gif" width="230" height="2"><br><a href="';
  98.     J := Pos(Tmp, Str);
  99.     If J > 0 Then Begin
  100.       K := J + Length(Tmp);
  101.       Tmp := Copy(Str, K, Length(Str) - K + 1);
  102.       K := Pos('"  alt="', Tmp);
  103.       If K > 0 Then Begin  (* URL *)
  104.         Url := Copy(Tmp, 1, K - 1);
  105.         Tmp1 := 'class="periwinkle">';
  106.         J := Pos(Tmp1, Tmp);
  107.         If J > 0 Then Begin (* Title *)
  108.           K := Pos('</a></td>', Tmp);
  109.           Title := Copy(Tmp, J + Length(Tmp1), K - (J + Length(Tmp1)));
  110.           HTMLDecode(Title);
  111.           I := I + 1; (* Episode Number *)
  112.           Str := Page . GetString(I);
  113.           J := Pos('<br>', Str);
  114.           If J > 0 Then Begin
  115.             K := Pos('</td>', Str);
  116.             EpisodeNo := Copy(Str, J + 4, K - (J + 4));
  117.             PickTreeAdd(EpisodeNo + ' - ' + Title, 'http://www.startrek.com' + Url); (* Add Episode to the tree *)
  118.           End;
  119.         End;
  120.       End;
  121.     End;
  122.     I := I + 1;
  123.   End;
  124.   ShowEpisodes := PickTreeExec(EpisodeURL);
  125. End;
  126.  
  127. Procedure ProcessEpisode;
  128. Var
  129.   Page      : TStringList;
  130.   PagePhoto : TStringList;
  131.   I, J, K   : Integer;
  132.   Str       : String;
  133.   Tmp, Tmp1 : String;
  134.   AirDate   : String;
  135.   StarDate  : String;
  136.   EpisodeNo : String;
  137.   Photo     : Boolean;
  138. Begin
  139.   SetField(fieldTranslatedTitle, GetField(fieldOriginalTitle));
  140.   Page := TStringList . Create;
  141.   Photo:= FALSE;
  142.   Page . Text := GetPage(EpisodeURL);
  143.   I := 1;
  144.   While I < Page . Count Do Begin
  145.     Str := Page . GetString(I);
  146.     (* Title *)
  147.     J := Pos('<span class="episodetitle">', Str);
  148.     If J > 0 Then Begin
  149.       Str := CleanString(Str);
  150.       SetField(fieldOriginalTitle, Str);
  151.     end else Begin
  152.       (* Air Date *)
  153.       J := Pos('<span class="mainwhite">Air Date:</span>', Str);
  154.       If J > 0 Then Begin
  155.         Tmp := Copy(Str, J + 47, 4);
  156.         SetField(fieldYear, Tmp);
  157.       end else Begin
  158.         (* Synopsis *)
  159.         J := Pos('<span class="headlinewhite">Synopsis</span>', Str);
  160.         If J > 0 Then Begin
  161.           I := I + 34;
  162.           Str := Page . GetString(I);
  163.           Str := CleanString(Str);
  164.           SetField(fieldDescription, Str);
  165.         End Else Begin
  166.           (* Cast = Actors *)
  167.           J := Pos('<span class="mainwhite">Cast:</span>', Str);
  168.           If J > 0 Then Begin
  169.             I := I + 4;
  170.             Tmp := Page . GetString(I);
  171.             Tmp1 := '';
  172.             While Length(Tmp) <> 0 Do Begin
  173.               Tmp := CleanString(Tmp);
  174.               I := I + 4;
  175.               Str := Page . GetString(I);
  176.               Str := CleanString(Str);
  177.               Tmp1 := Tmp1 + Tmp + ' as ' + Str + #13#10;
  178.               I := I + 4;
  179.               Tmp := Page . GetString(I);
  180.             End;
  181.             Tmp := GetField(fieldActors);
  182.             SetField(fieldActors, Tmp + Tmp1);
  183.           End Else Begin
  184.             (* Guest Cast = Actors *)
  185.             J := Pos('<span class="mainwhite">Guest Cast:</span>', Str);
  186.             If J > 0 Then Begin
  187.               I := I + 5;
  188.               Tmp := Page . GetString(I);
  189.               Tmp1 := '';
  190.               While Length(Tmp) <> 0 Do Begin
  191.               Tmp := CleanString(Tmp);
  192.                 I := I + 4;
  193.                 Str := Page . GetString(I);
  194.                 Str := CleanString(Str);
  195.                 Tmp1 := Tmp1 + Tmp + ' as ' + Str + #13#10;
  196.                 I := I + 4;
  197.                 Tmp := Page . GetString(I);
  198.               End;
  199.               Tmp := GetField(fieldActors);
  200.               SetField(fieldActors, Tmp + Tmp1);
  201.             End Else Begin
  202.               (* Creative Staff = Director + Comments *)
  203.               J := Pos('<span class="mainwhite">Creative Staff:</span>', Str);
  204.               If J > 0 Then Begin
  205.                 I := I + 2;
  206.                 Str := Page . GetString(I);
  207.                 While Str <> '</table>' Do Begin
  208.                   Tmp := CleanString(Str);
  209.                   If Tmp = 'Director:' Then Begin
  210.                     I := I + 2;
  211.                     Str := Page . GetString(I);
  212.                     Str := CleanString(Str);
  213.                     SetField(fieldDirector, Str);
  214.                   End Else If Tmp <> '' Then Begin
  215.                     Str := GetField(fieldComments);
  216.                     SetField(fieldComments, Str + Tmp + #13#10);
  217.                   End;
  218.                   I := I + 1;
  219.                   Str := Page . GetString(I);
  220.                 End;
  221.               End Else Begin
  222.                 (* Episode Number *)
  223.                 J := Pos('<span class="mainwhite">Production:</span>', Str);
  224.                 If J > 0 Then Begin
  225.                   Str := Copy(Str, J, Length(Str) - J);
  226.                   Str := CleanString(Str);
  227.                   Tmp := GetField(fieldComments);
  228.                   SetField(fieldComments, Tmp + Str + #13#10);
  229.                 End Else Begin
  230.                   (* Star Date *)
  231.                   J := Pos('<span class="mainwhite">Stardate:</span>', Str);
  232.                   If J > 0 Then Begin
  233.                     I := I + 2;
  234.                     Str := Page . GetString(I);
  235.                     Str := CleanString(Str);
  236.                     If Str <> '' Then Begin
  237.                       Tmp := GetField(fieldComments);
  238.                       SetField(fieldComments, Tmp + 'Stardate: ' + Str + #13#10);
  239.                     End;
  240.                   End Else Begin
  241.                     (* Picture *)
  242.                     Tmp := '<a class="periwinkle" HREF="javascript:openwindow(''/startrek/mediaview?';
  243.                     J := Pos(Tmp, Str);
  244.                     If (Photo = FALSE) And (J > 0) Then Begin
  245.                       K := Pos(''',''mediapopup', Str);
  246.                       Tmp := Copy(Str, J + Length(Tmp), K - (J + Length(Tmp)));
  247.                       PagePhoto := TStringList . Create;
  248.                       PagePhoto . Text := GetPage('http://www.startrek.com/startrek/mediaview?' + Tmp);
  249.                       Str := PagePhoto . GetString(35);
  250.                       J := Pos('/imageuploads/', Str);
  251.                       K := Pos('jpg', Str);
  252.                       Str := Copy(Str, J, K - J + 3);
  253.                       GetPicture('http://www.startrek.com/' + Str);
  254.                       PagePhoto . Free;
  255.                       Photo := TRUE;
  256.                     End;
  257.                   End;
  258.                 End;
  259.               End;
  260.             End;
  261.           End;
  262.         End;
  263.       End;
  264.     End;
  265.     I := I + 1;
  266.   End;
  267.   SetField(fieldCountry, 'United States');
  268.   SetField(fieldProducer, 'Paramount Pictures');
  269.   SetField(fieldCategory, 'Star Trek');
  270.   Page . Free;
  271. end;
  272.  
  273. begin
  274.   If CheckVersion(3,5,0) Then Begin
  275.     If ShowSeries Then Begin
  276.       If ShowEpisodes Then Begin
  277.         ProcessEpisode;
  278.         //DisplayResults;
  279.       End;
  280.     End;
  281.   End
  282.     Else
  283.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  284. end.
  285.